home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1993…stman Always Clicks Twice / ADC Developer CD (1993-01) (''The Postman Always Clicks Twice'')_iso / Dev.CD 199301.iso / Technical Documentation / Sample Code / DTS.Lib & Samples / DTS.Draw / App.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-22  |  5.0 KB  |  169 lines  |  [TEXT/MPS ]

  1. #ifndef __APPHEADER__
  2. #define __APPHEADER__
  3.  
  4. #ifndef __DTSLib__
  5. #include "DTS.Lib.h"
  6. #endif
  7.  
  8. #ifndef __PRINTING__
  9. #include <Printing.h>
  10. #endif
  11.  
  12. #ifndef __TREEOBJ__
  13. #include <TreeObj.h>
  14. #endif
  15.  
  16. /********/
  17.  
  18. /* If you are unfamiliar with programming with the DTS.LIB..framework, you probably want to
  19. ** read the file "=How to write your app", which is found at the same level as the
  20. ** directory for this project. */
  21.  
  22. typedef struct {
  23.     DocHeaderInfo    fhInfo;        /* Doc header info (version, print record, window loc. ) */
  24.     TreeObjHndl        root;
  25.                                 /***** Start of custom file info. *****/
  26. } TheDoc;
  27.  
  28. /* Below is the master document structure.  All DTS.LIB..framework documents use this structure.
  29. ** For each unique document type, union in a sub-structure for the document-specific
  30. ** information.  In the case of DTS.Draw, there is only one document type.  The structure for
  31. ** this document type is defined just above.  Even though there is only one, it is still
  32. ** placed in a union.  This allows easy addition of additional document types later.
  33. **
  34. ** The fileState and connect fields are expected and managed by DTS.LIB..framework.  Also, the
  35. ** first two fields in the app-specific portion of the document are expected, namely
  36. ** the fhInfo and root fields. */
  37.  
  38. typedef struct FileRec {
  39.     FileStateRec    fileState;        /* DTS.LIB..framework expects this structure here. */
  40.     ConnectRec        connect;        /* DTS.LIB..framework expects this structure here. */
  41.     union {
  42.         TheDoc    doc;                /* Union in each document type here. */
  43.     } d;
  44. } FileRec;
  45.  
  46. /* Below is the definition of the hierarchical document's root object.  If you are using
  47. ** the hierarchical document package TreeObj, then you will need at least this object.
  48. ** TreeObj expects the first two fields to be undo and frHndl, as shown below.  You can
  49. ** add fields after these two fields.  If you use TreeObj, the root object and all of its
  50. ** children are automatically saved and read from disk.
  51. ** Note that the definition for the root object includes a prototype.  Each object is
  52. ** automatically called by DTS.LIB..framework at appropriate times.  The prototype defines the
  53. ** function that will be called for this object.  See the files "=How to write your app"
  54. ** and "=Using TreeObj.c" for more information. */
  55.  
  56. long    TRootObj(TreeObjHndl hndl, short message, long data);
  57. typedef struct {
  58.     TreeObjHndl    undo;        /* This structure may be added to, but */
  59.     FileRecHndl    frHndl;        /* these two first fields must remain. */
  60.     short        numSelected;
  61. } RootObj;
  62.  
  63. /* This definition allows us to access the fields that are in common between the below objects. */
  64.  
  65. typedef struct {
  66.     Boolean    selected;
  67.     Rect    rect;
  68. } CommonObj;
  69.  
  70.  
  71. /* Below are the definitions of the various DTS.Draw tool palette objects. */
  72.  
  73. long    TRectObj(TreeObjHndl hndl, short message, long data);
  74. typedef struct {
  75.     Boolean    selected;
  76.     Rect    rect;
  77. } RectObj;
  78.  
  79.  
  80. long    TRRectObj(TreeObjHndl hndl, short message, long data);
  81. typedef struct {
  82.     Boolean    selected;
  83.     Rect    rect;
  84.     short    width, height;
  85. } RRectObj;
  86.  
  87.  
  88. long    TOvalObj(TreeObjHndl hndl, short message, long data);
  89. typedef struct {
  90.     Boolean    selected;
  91.     Rect    oval;
  92. } OvalObj;
  93.  
  94.  
  95. OSErr    CalcPiePoints(TreeObjHndl hndl);
  96. long    TPieObj(TreeObjHndl hndl, short message, long data);
  97. typedef struct {
  98.     Boolean    selected;
  99.     Rect    arc;
  100.     short    arcStart;
  101.     short    arcLength;
  102.     Point    center;
  103.     Point    arcBegin;
  104.     Point    arcEnd;
  105. } PieObj;
  106.  
  107.  
  108. long    TGroupObj(TreeObjHndl hndl, short message, long data);
  109. typedef struct {
  110.     Boolean    selected;
  111.     Rect    group;
  112. } GroupObj;
  113.  
  114.  
  115. #define VFLIPOBJ 0x01
  116. #define HFLIPOBJ 0x02
  117.  
  118.  
  119. /* Here are some macro definitions to make dereferencing document objects easier. */
  120.  
  121. #define mDerefRoot(hndl)     ((RootObj*)((*hndl) + 1))
  122. #define mDerefCommon(hndl)   ((CommonObj*)((*hndl) + 1))
  123. #define mDerefRect(hndl)     ((RectObj*)((*hndl) + 1))
  124. #define mDerefRRect(hndl)    ((RRectObj*)((*hndl) + 1))
  125. #define mDerefOval(hndl)     ((OvalObj*)((*hndl) + 1))
  126. #define mDerefPie(hndl)      ((PieObj*)((*hndl) + 1))
  127. #define mDerefGroup(hndl)    ((GroupObj*)((*hndl) + 1))
  128.  
  129.  
  130. /********/
  131.  
  132. #define kMaxNumUndos    64
  133. #define kNumSaveUndos    8
  134.  
  135. #define RECTOBJ            16
  136. #define RRECTOBJ        17
  137. #define OVALOBJ            18
  138. #define PIEOBJ            19
  139. #define GROUPOBJ        65
  140.  
  141. #define kNumTreeObjs    66        /* Minimum number of objects is 16. */
  142.  
  143.  
  144. /********/
  145.  
  146. /* These values are passed to the DTS.LIB..framework function Initialize(). */
  147. #define kMinHeap    64 * 1024        /* Needs at least 64k of heap space. */
  148. #define kMinSpace    64 * 1024        /* Needs this much after calling PurgeSpace. */
  149.  
  150.  
  151. #define kwAppWindow            (kwGrowIcon | kwHScrollLessGrow | kwVScrollLessGrow | kwVisible | kwOpenAtOldLoc)
  152. #define kwClipboardWindow    (kwGrowIcon | kwHScrollLessGrow | kwVScrollLessGrow | kwHideOnClose)
  153. #define kwToolWindow        (kwHideOnClose | kwIsPalette)
  154.     /* Above are the attributes for the various document/window types for this application. */
  155.  
  156.  
  157. #define kVersion        100        /* Document versions, not application versions. */
  158. #define kMinVersion        100
  159. #define kMaxVersion        100
  160.  
  161. #define kMaxNumWindows        65535        /* No limit on the number of windows. */
  162.  
  163.  
  164. #define kToolHeight 20
  165. #define kNumTools   5
  166.  
  167.  
  168. #endif __APPHEADER__
  169.